#include <glib.h>

void _list_interger_print_func(gpointer data, gpointer user_data)
{
    g_print("data is: %d, user_data is: %s \n", GPOINTER_TO_INT(data), (gchar *)user_data);
}

gint main(gint argc, gchar **argv)
{
    GList *list1 = NULL;
    GList *list2 = NULL;

    list1 = g_list_append(list1, GINT_TO_POINTER(1));
    list1 = g_list_append(list1, GINT_TO_POINTER(5));
    list2 = g_list_append(list2, GINT_TO_POINTER(3));
    list2 = g_list_append(list2, GINT_TO_POINTER(7));

    g_list_foreach(list1, _list_interger_print_func, (gchar *)"list1");
    g_list_foreach(list2, _list_interger_print_func, (gchar *)"list2");

    list1 = g_list_concat(list1, list2);
    g_list_foreach(list1, _list_interger_print_func, (gchar *)"list1-concat");
    g_list_foreach(list2, _list_interger_print_func, (gchar *)"list2-concat");

    g_list_free(list1);
    // g_list_free(list2);  //should not free list2

    return 0;
}